package com.zzhua.filter;

import javax.servlet.*;
import java.io.IOException;

/**
 * @see org.apache.catalina.core.ApplicationFilterChain#doFilter (责任链模式：filter和servlet的运行顺序,以及调用关系)
 */
public class UserFilter1 implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("userFilter1 init...自定义过滤器userFilter1初始化");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("userFilter1 doFilter...自定义过滤器userFilter1执行");
        filterChain.doFilter(servletRequest,servletResponse); // 放行, 不执行这一句将会拦截掉请求, 不会执行后面的filter和servlet
    }

    @Override
    public void destroy() {
        System.out.println("userFilter1 destroy...自定义过滤器userFilter1销毁");
    }
}
